<?php

namespace frontend\models;

use Yii;

/**
 * This is the model class for table "{{%userinfo}}".
 *
 * @property integer $userinfo_id
 * @property integer $user_id
 * @property string $img
 * @property integer $area_id
 * @property string $nickname
 * @property string $phone
 * @property string $email
 * @property string $backup
 * @property integer $seven_user_user_id
 *
 * @property User $sevenUserUser
 */
class UserinfoModel extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%userinfo}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['user_id', 'area_id', 'seven_user_user_id'], 'integer'],
            [['seven_user_user_id'], 'required'],
            [['img', 'nickname', 'phone', 'email', 'backup'], 'string', 'max' => 45],
            [['seven_user_user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['seven_user_user_id' => 'user_id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'userinfo_id' => Yii::t('app', 'Userinfo ID'),
            'user_id' => Yii::t('app', 'User ID'),
            'img' => Yii::t('app', 'Img'),
            'area_id' => Yii::t('app', 'Area ID'),
            'nickname' => Yii::t('app', 'Nickname'),
            'phone' => Yii::t('app', 'Phone'),
            'email' => Yii::t('app', 'Email'),
            'backup' => Yii::t('app', 'Backup'),
            'seven_user_user_id' => Yii::t('app', 'Seven User User ID'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getSevenUserUser()
    {
        return $this->hasOne(User::className(), ['user_id' => 'seven_user_user_id']);
    }
}
